
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" template="/template/main.xhtml">

	<ui:define name="body">
		<h:form prependId="false">

			<p:toolbar>
				<p:toolbarGroup align="left">
					<p:commandButton value="#{messages['button.save']}" action="#{licitacaoEditMB.insert}"
						rendered="#{!licitacaoEditMB.updateMode}" ajax="false" />
					<p:commandButton value="#{messages['button.save']}" action="#{licitacaoEditMB.update}"
						rendered="#{licitacaoEditMB.updateMode}" ajax="false" />
					<p:commandButton value="#{messages['button.delete']}" onclick="confirmation.show()"
						rendered="#{licitacaoEditMB.updateMode}" type="button" immediate="true" ajax="false" />
					<p:confirmDialog message="#{messages['label.confirm.delete']}" showEffect="bounce" hideEffect="explode"
						header="#{messages['label.dialog.delete']}" severity="alert" widgetVar="confirmation">
						<h:commandButton value="#{messages['button.dialog.yes']}" action="#{licitacaoEditMB.delete}" immediate="true"
							ajax="false" />
						<h:commandButton value="#{messages['button.dialog.no']}" onclick="confirmation.hide()" type="button" />
					</p:confirmDialog>
				</p:toolbarGroup>
			</p:toolbar>

			<br />

			<p:fieldset legend="#{messages['licitacao.label.dadosGerais']}" toggleable="true" toggleSpeed="500">
				<h:panelGrid id="fields" columns="2">
					
					
					<h:outputLabel value="#{messages['licitacao.label.id']}: " for="id" styleClass="text-input" />
					<h:panelGrid columns="2">
						<h:outputText id="id" value="#{licitacaoEditMB.bean.id}" />
						<p:message for="id" />
					</h:panelGrid>
	
					<h:outputLabel value="#{messages['licitacao.label.unidadeOrcamentaria']}: " for="unidadeOrcamentaria" styleClass="text-input" />
					<h:panelGrid columns="5">
						<h:selectOneMenu value="#{licitacaoEditMB.unidadeOrcamentaria}" id="unidadeOrcamentaria" style="width: 350px;"
							title="#{messages['licitacao.label.unidadeOrcamentaria']}" required="true"
							requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">
							<f:selectItem itemLabel="Selecione" itemValue="" />	
	 						<f:selectItems value="#{licitacaoEditMB.unidadeOrcamentarias}"></f:selectItems>
						</h:selectOneMenu>
					    <p:message for="unidadeOrcamentaria" />
	
						<h:outputLabel value="#{messages['licitacao.label.obra']}: " for="obra" styleClass="text-input" />
						<h:selectOneMenu value="#{licitacaoEditMB.obra}" id="obra" style="width: 550px;"
							title="#{messages['licitacao.label.obra']}" required="true"
							requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">
							<f:selectItem itemLabel="Selecione" itemValue="" />	
	 						<f:selectItems value="#{licitacaoEditMB.obras}"></f:selectItems>
						</h:selectOneMenu>
					    <p:message for="obra" />
					</h:panelGrid>
					
					<h:outputLabel value="#{messages['licitacao.label.numeroLicitacao']}: " for="numeroLicitacao" styleClass="text-input" />
					<h:panelGrid columns="5">
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="numeroLicitacao" value="#{licitacaoEditMB.bean.numeroLicitacao}"
							title="#{messages['licitacao.alt.numeroLicitacao']}" />
						<p:message for="numeroLicitacao" />

						<h:outputLabel value="#{messages['licitacao.label.situacao']}: " for="situacaoLicitacao" styleClass="text-input" />
						<h:selectOneMenu value="#{licitacaoEditMB.situacaoLicitacao}" id="situacaoLicitacao" style="width: 150px;"
							title="#{messages['licitacao.label.situacao']}" required="true"
							requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">
							<f:selectItem itemLabel="Selecione" itemValue="" />	
	 						<f:selectItems value="#{licitacaoEditMB.situacaoLicitacaos}"></f:selectItems>
						</h:selectOneMenu>
					    <p:message for="situacaoLicitacao" />
					</h:panelGrid>

					<h:outputLabel value="#{messages['licitacao.label.dataAberturaPropostas']}: " for="dataAberturaPropostas" styleClass="text-input" />
					<h:panelGrid columns="11">
						<p:calendar id="dataAberturaPropostas" value="#{licitacaoEditMB.bean.dataAberturaPropostas}"
						   pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true" size="12"
						   locale="#{currentLocale}" title="#{messages['licitacao.alt.dataAberturaPropostas']}" />
					   <p:message for="dataAberturaPropostas" />

						<h:outputLabel value="#{messages['licitacao.label.dataAssinaturaContrato']}: " for="dataAssinaturaContrato" styleClass="text-input" />
						<p:calendar id="dataAssinaturaContrato" value="#{licitacaoEditMB.bean.dataAssinaturaContrato}"
						   pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true" size="12"
						   locale="#{currentLocale}" title="#{messages['licitacao.alt.dataAssinaturaContrato']}" />
					   <p:message for="dataAssinaturaContrato" />

						<h:outputLabel value="#{messages['licitacao.label.dataInicio']}: " for="dataInicio" styleClass="text-input" />
						<p:calendar id="dataInicio" value="#{licitacaoEditMB.bean.dataInicio}"
						   pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true"  size="12"
						   locale="#{currentLocale}" title="#{messages['licitacao.alt.dataInicio']}" />
					   <p:message for="dataInicio" />
								
						<h:outputLabel value="#{messages['licitacao.label.dataConclusao']}: " for="dataConclusao" styleClass="text-input" />
						<p:calendar id="dataConclusao" value="#{licitacaoEditMB.bean.dataConclusao}"
						   pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true" size="12"
						   locale="#{currentLocale}" title="#{messages['licitacao.alt.dataConclusao']}" />
					   <p:message for="dataConclusao" />
					</h:panelGrid>

					<h:outputLabel value="#{messages['licitacao.label.tipoLicitacao']}: " for="tipoLicitacao" styleClass="text-input" />
					<h:panelGrid columns="8">
						<h:selectOneMenu value="#{licitacaoEditMB.tipoLicitacao}" id="tipoLicitacao" style="width: 150px;"
							title="#{messages['licitacao.label.tipoLicitacao']}" required="true"
							requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">
							<f:selectItem itemLabel="Selecione" itemValue="" />	
	 						<f:selectItems value="#{licitacaoEditMB.tipoLicitacaos}"></f:selectItems>
						</h:selectOneMenu>
					    <p:message for="tipoLicitacao" />

						<h:outputLabel value="#{messages['licitacao.label.numeroModalidade']}: " for="numeroModalidade" styleClass="text-input" />
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="numeroModalidade" value="#{licitacaoEditMB.bean.numeroModalidade}"
							title="#{messages['licitacao.alt.numeroModalidade']}" />
						<p:message for="numeroModalidade" />
	
						<h:outputLabel value="#{messages['licitacao.label.numeroContrato']}: " for="numeroContrato" styleClass="text-input" />
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="numeroContrato" value="#{licitacaoEditMB.bean.numeroContrato}"
							title="#{messages['licitacao.alt.numeroContrato']}" />
						<p:message for="numeroContrato" />
					</h:panelGrid>
					
					<h:outputLabel value="#{messages['licitacao.label.dotacaoOrcamentaria']}: " for="dotacaoOrcamentaria" styleClass="text-input" />
					<h:panelGrid columns="5">
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="dotacaoOrcamentaria" value="#{licitacaoEditMB.bean.dotacaoOrcamentaria}"
							title="#{messages['licitacao.alt.dotacaoOrcamentaria']}" />
						<p:message for="dotacaoOrcamentaria" />

						<h:outputLabel value="#{messages['licitacao.label.valorOrcamentoEstimativo']}: " for="valorOrcamentoEstimativo" styleClass="text-input" />
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="valorOrcamentoEstimativo" value="#{licitacaoEditMB.bean.valorOrcamentoEstimativo}"
							title="#{messages['licitacao.alt.valorOrcamentoEstimativo']}" />
						<p:message for="valorOrcamentoEstimativo" />
					</h:panelGrid>

					<h:outputLabel value="#{messages['licitacao.label.objetoLicitacao']}: " for="objetoLicitacao" styleClass="text-input" />
					<h:panelGrid columns="2">
						<h:inputTextarea id="objetoLicitacao" value="#{licitacaoEditMB.bean.objetoLicitacao}" style="width: 700px;" rows="3" 
							title="#{messages['licitacao.alt.objetoLicitacao']}" />
						<p:message for="objetoLicitacao" />
					</h:panelGrid>
				</h:panelGrid>
			</p:fieldset>
		</h:form>

		<p:spacer height="20" width="20"/>  

		<h:form prependId="false">
			<p:fieldset legend="#{messages['licitacao.label.itens']}" toggleable="true" toggleSpeed="500">
				<h:panelGrid columns="1"  id="fields2" >
		
					<p:dataTable id="listItem" var="bean" value="#{licitacaoEditMB.bean.obra.listaItemTabelaPrecoObra}" rowIndexVar="rowIndex" >
						<f:facet name="header">#{messages['obra.itens.list.table.title']}</f:facet>
	
						<p:column sortBy="#{bean.agrupamentoItem.descricao}"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.agrupamentoItem']}</f:facet>
								<h:outputText value="#{bean.agrupamentoItem.descricao}" />
						</p:column>
	
						<p:column sortBy="#{bean.localItem.descricao}"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.localItem']}</f:facet>
								<h:outputText value="#{bean.localItem.descricao}" />
						</p:column>
	
						<p:column sortBy="#{bean.itemTabelaPreco.descricao}"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.itemTabelaPreco']}</f:facet>
								<h:outputText value="#{bean.itemTabelaPreco.descricao}" />
						</p:column>
	
						<p:column sortBy="#{bean.itemTabelaPreco.unidade.descricao}" width="20"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.unidadeMedida']}</f:facet>
								<h:outputText value="#{bean.itemTabelaPreco.unidade.descricao}" />
						</p:column>
	
						<p:column sortBy="#{bean.itemTabelaPreco.valorUnitario}" width="20"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.valorUnitario']}</f:facet>
								<h:outputText value="#{bean.itemTabelaPreco.valorUnitario}" />
						</p:column>
	
						<p:column sortBy="#{bean.periodoInicial}"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.periodoInicialItem']}</f:facet>
								<h:outputText value="#{bean.periodoInicial}" />
						</p:column>
	
						<p:column sortBy="#{bean.periodoFinal}"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.periodoFinalItem']}</f:facet>
								<h:outputText value="#{bean.periodoFinal}" />
						</p:column>
	
						<p:column sortBy="#{bean.quantidade}" width="20"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.quantidade']}</f:facet>
								<h:outputText value="#{bean.quantidade}" />
						</p:column>
	
						<p:column sortBy="#{bean.valorUnitarioComBDI }" width="20"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.valorUnitarioComBDI']}</f:facet>
								<h:outputText value="#{bean.valorUnitarioComBDI}" />
						</p:column>
	
						<p:column sortBy="#{bean.valorFinalItem}" width="20"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.valorFinalItem']}</f:facet>
								<h:outputText value="#{bean.valorFinalItem}" />
						</p:column>
	



						<p:column sortBy="#{bean.periodoInicial}"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.periodoInicialItem']}</f:facet>
								<h:outputText value="#{bean.periodoInicial}" />
						</p:column>
	
						<p:column sortBy="#{bean.periodoFinal}"    style="font-size:12">
							<f:facet name="header">#{messages['obra.label.periodoFinalItem']}</f:facet>
								<h:outputText value="#{bean.periodoFinal}" />
						</p:column>
	
						<p:column sortBy="#{bean.valorFinalItem}" width="20"     style="font-size:12">
							<f:facet name="header">#{messages['obra.label.valorFinalItem']}</f:facet>
								<h:outputText value="#{bean.valorFinalItem}" />
						</p:column>
	
					</p:dataTable>

					<br/>

					<h:commandButton value="#{messages['button.exportarCronograma']}" action="#" ajax="true" actionListener="#{licitacaoEditMB.exportarCronograma}" >
		    			<f:ajax execute="fields2" render="fields2" />
		    	   	</h:commandButton>

				</h:panelGrid>
			</p:fieldset>
		</h:form>
		
		<p:spacer height="20" width="20"/>  

		<h:form prependId="false">
			<p:fieldset legend="#{messages['licitacao.label.empresas']}" toggleable="true" toggleSpeed="500">
				<h:panelGrid columns="2"  id="fields3" >

					<h:outputLabel value="#{messages['licitacao.label.nomeRazaoSocial']}: " for="nomeRazaoSocial" styleClass="text-input" />
					<h:panelGrid columns="5" >
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="nomeRazaoSocial" value="#{licitacaoEditMB.nomeRazaoSocial}" size="70"
							title="#{messages['licitacao.alt.nomeRazaoSocial']}" />
						<p:message for="nomeRazaoSocial" />

						<h:outputLabel value="#{messages['licitacao.label.cnpj']}: " for="cnpj" styleClass="text-input" />
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="cnpj" value="#{licitacaoEditMB.cnpj}" size="20"
							title="#{messages['licitacao.alt.cnpj']}" />
						<p:message for="cnpj" />

					</h:panelGrid>

					<h:outputLabel value="#{messages['licitacao.label.nomeEngenheiroResponsavel']}: " for="nomeEngenheiroResponsavel" styleClass="text-input" />
					<h:panelGrid columns="8" >
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="nomeEngenheiroResponsavel" value="#{licitacaoEditMB.nomeEngenheiroResponsavel}" size="50"
							title="#{messages['licitacao.alt.nomeEngenheiroResponsavel']}" />
						<p:message for="nomeEngenheiroResponsavel" />
	
						<h:outputLabel value="#{messages['licitacao.label.numCrea']}: " for="numCrea" styleClass="text-input" />
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="numCrea" value="#{licitacaoEditMB.numCrea}" size="50"
							title="#{messages['licitacao.alt.numCrea']}" />
						<p:message for="numCrea" />

						<h:outputLabel value="#{messages['licitacao.label.ufCrea']}: " for="ufCrea" styleClass="text-input" />
						<h:selectOneMenu value="#{licitacaoEditMB.ufCrea}" id="ufCrea" style="width: 150px;"
							title="#{messages['licitacao.label.ufCrea']}" required="true"
							requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">
							<f:selectItem itemLabel="Selecione" itemValue="" />	
	 						<f:selectItems value="#{licitacaoEditMB.ufCreas}"></f:selectItems>
						</h:selectOneMenu>
					    <p:message for="ufCrea" />

					</h:panelGrid>

					<h:outputLabel value="#{messages['licitacao.label.nomeContato']}: " for="nomeContato" styleClass="text-input" />
					<h:panelGrid columns="8" >
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="nomeContato" value="#{licitacaoEditMB.nomeContato}" size="50"
							title="#{messages['licitacao.alt.nomeContato']}" />
						<p:message for="nomeContato" />
	
						<h:outputLabel value="#{messages['licitacao.label.foneContato']}: " for="foneContato" styleClass="text-input" />
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="foneContato" value="#{licitacaoEditMB.foneContato}" size="50"
							title="#{messages['licitacao.alt.foneContato']}" />
						<p:message for="foneContato" />
					</h:panelGrid>

					<h:outputLabel value="#{messages['licitacao.label.valorProposta']}: " for="valorProposta" styleClass="text-input" />
					<h:panelGrid columns="5" >
						<h:inputText required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" id="valorProposta" value="#{licitacaoEditMB.valorProposta}" size="50"
							title="#{messages['licitacao.alt.valorProposta']}" />
						<p:message for="valorProposta" />
						<h:outputLabel value="#{messages['licitacao.label.indVencedora']}: " for="indVencedora" styleClass="text-input" />
						<h:selectOneRadio styleClass="tableRadios" id="indVencedora" value="#{licitacaoEditMB.indVencedora}" 
					    	required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">  
				             <f:selectItem itemLabel="Sim" itemValue="S" />
				             <f:selectItem itemLabel="Não" itemValue="N" />
				         </h:selectOneRadio>
						<p:message for="indVencedora" />
					</h:panelGrid>




					<f:facet name="footer">
				    	<h:panelGroup>
				    	
							<h:commandButton value="#{messages['button.add']}"  action="#{licitacaoEditMB.adicionarEmpresa()}" ajax="true" >
				    			<f:ajax execute="fields3" render="fields3" />
				    	   	</h:commandButton>

							<p:message for="listEmpresas"/>
							<p:dataTable id="listEmpresas" var="bean" value="#{licitacaoEditMB.bean.listaLicitacaoEmpresa}" rowIndexVar="rowIndex" >
								<f:facet name="header">#{messages['licitacao.empresa.list.table.title']}</f:facet>
			
								<p:column style="width:5%;" sortBy="#{rowIndex}">
									<f:facet name="header">#{messages['button.remove']}</f:facet>
									<h:commandButton value="#{messages['button.remove']}" action="#{licitacaoEditMB.removerEmpresa()}" ajax="true" >
						    			<f:ajax execute="list" render="list" immediate="true"/>
										<f:setPropertyActionListener target="#{licitacaoEditMB.posicaoEmpresa}" value="#{rowIndex}" />
									</h:commandButton>
								</p:column>
			
								<p:column sortBy="#{bean.cnpj}">
									<f:facet name="header">#{messages['licitacao.label.cnpj']}</f:facet>
										<h:outputText value="#{bean.cnpj}" />
								</p:column>

								<p:column sortBy="#{bean.nomeRazaoSocial}">
									<f:facet name="header">#{messages['licitacao.label.nomeRazaoSocial']}</f:facet>
										<h:outputText value="#{bean.nomeRazaoSocial}" />
								</p:column>

								<p:column sortBy="#{bean.nomeContato}">
									<f:facet name="header">#{messages['licitacao.label.nomeContato']}</f:facet>
										<h:outputText value="#{bean.nomeContato}" />
								</p:column>

								<p:column sortBy="#{bean.foneContato}">
									<f:facet name="header">#{messages['licitacao.label.foneContato']}</f:facet>
										<h:outputText value="#{bean.foneContato}" />
								</p:column>

								<p:column sortBy="#{bean.nomeEngenheiroResponsavel}">
									<f:facet name="header">#{messages['licitacao.label.nomeEngenheiroResponsavel']}</f:facet>
										<h:outputText value="#{bean.nomeEngenheiroResponsavel}" />
								</p:column>

								<p:column sortBy="#{bean.numCrea}">
									<f:facet name="header">#{messages['licitacao.label.numCrea']}</f:facet>
										<h:outputText value="#{bean.numCrea}" />
								</p:column>

								<p:column sortBy="#{bean.valorProposta}">
									<f:facet name="header">#{messages['licitacao.label.valorProposta']}</f:facet>
										<h:outputText value="#{bean.valorProposta}" />
								</p:column>

								<p:column sortBy="#{bean.indVencedora}">
									<f:facet name="header">#{messages['licitacao.label.indVencedora']}</f:facet>
										<h:outputText value="Sim" rendered="#{bean.indVencedora eq 'S'}" />
										<h:outputText value="Não" rendered="#{bean.indVencedora eq 'N'}" />
								</p:column>

							</p:dataTable>
	
							<br/>
	
				    	</h:panelGroup>
				    </f:facet>	



				</h:panelGrid>
			</p:fieldset>
		</h:form>
		
	</ui:define>
</ui:composition>